package main

import (
	"io/ioutil"
	"net/http"

	"github.com/gin-gonic/gin"
	"gocv.io/x/gocv"
)

func main() {
	app := gin.Default()
	app.POST("/server", TestHandle)
	app.Run(":8888")
}

func TestHandle(c *gin.Context) {
	// dest, _ ,_ := image.Decode(c.Request.Body)
	image, _ := ioutil.ReadAll(c.Request.Body)
	defer c.Request.Body.Close()
	mat, err := gocv.IMDecode(image, gocv.IMReadColor)
	if err != nil {
		return
	}
	win := gocv.NewWindow("test")
	win.IMShow(mat)
	gocv.WaitKey(0)
	c.String(http.StatusOK, "ok")
}
